﻿namespace MsTestUtilities.SolutionAnalysis
{
    public class Reference : IItem
    {
        private const string PrivateMetadata = "Private";
        private const string HintPathMetadata = "HintPath";

        public const string ElementName = "Reference";

        private Item _item;

        public string Path { get { return _item.Include; } }

        public CsProject ParentProject { get; set; }

        public Reference(CsProject project, Item item)
        {
            _item = item;
            ParentProject = project;
        }

        public string Include
        {
            get { return _item.Include; }
        }

        public string HintPath { get { return _item.GetMetadata(HintPathMetadata); } }

        public bool CopyLocal { get { return Private; } }

        public bool Private
        {
            get
            {
                if (!_item.HasMetadata(PrivateMetadata))
                {
                    return _item.HasMetadata(HintPathMetadata);
                }

                return bool.Parse(_item.GetMetadata(PrivateMetadata));
            }
        }
    }
}
